ff_vecs_t cetus_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
ff_vecs_t copilot_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
*/
xcsv_file.ofield = xcalloc(sizeof(queue), 1);
QUEUE_INIT(xcsv_file.ofield);
+ /*
+ * Provide a sane default for CSV _files_.
+ */
+ xcsv_file.type = ff_type_file;
xcsv_file.mkshort_handle = mkshort_new_handle();
}
char * extension; /* preferred filename extension (for wrappers)*/
void * mkshort_handle; /* handle for mkshort() */
+ ff_type type; /* format type for GUI wrappers. */
} xcsv_file_t;
long argtype;
} arglist_t;
+typedef enum {
+ ff_type_file = 1, /* normal format: useful to a GUI. */
+ ff_type_internal, /* fmt not useful with default options */
+ ff_type_serial, /* format describes a serial protoco (GUI can display port names) */
+} ff_type;
+
+/*
+ * Describe the file format to the caller.
+ */
typedef struct ff_vecs {
+ ff_type type;
ff_init rd_init;
ff_init wr_init;
ff_deinit rd_deinit;
}
ff_vecs_t gpl_vecs = {
+ ff_type_file,
gpl_rd_init,
gpl_wr_init,
gpl_rd_deinit,
ff_vecs_t easygps_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
ff_vecs_t garmin_vecs = {
+ ff_type_serial,
rw_init,
rw_init,
rw_deinit,
ff_vecs_t gcdb_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
}
ff_vecs_t geo_vecs = {
+ ff_type_file,
geo_rd_init,
geo_wr_init,
geo_rd_deinit,
ff_vecs_t geoniche_vecs =
{
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
ff_vecs_t gpilots_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
}
ff_vecs_t gpsdrive_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
ff_vecs_t gpspilot_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
ff_vecs_t gpsutil_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
};
ff_vecs_t gpx_vecs = {
+ ff_type_file,
gpx_rd_init,
gpx_wr_init,
gpx_rd_deinit,
ff_vecs_t holux_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
"FIELD_DELIMITER COMMA\n"
"RECORD_DELIMITER NEWLINE\n"
"BADCHARS COMMA\n"
+"FORMAT_TYPE INTERNAL\n"
"#\n"
"# HEADER STUFF:\n"
"FIELD_DELIMITER TAB\n"
"RECORD_DELIMITER NEWLINE\n"
"BADCHARS TAB\n"
+"FORMAT_TYPE INTERNAL\n"
"#\n"
"# INDIVIDUAL DATA FIELDS:\n"
ff_vecs_t magnav_vec = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
}
ff_vecs_t mag_vecs = {
+ ff_type_serial,
mag_rd_init,
mag_wr_init,
mag_deinit,
ff_vecs_t mapopolis_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
ff_vecs_t mapsend_vecs = {
+ ff_type_file,
mapsend_rd_init,
mapsend_wr_init,
mapsend_rd_deinit,
}
ff_vecs_t mps_vecs = {
+ ff_type_file,
mps_rd_init,
mps_wr_init,
mps_rd_deinit,
}
ff_vecs_t navicache_vecs = {
+ ff_type_file,
nav_rd_init,
nav_wr_init,
nav_rd_deinit,
}
ff_vecs_t nmea_vecs = {
+ ff_type_file,
nmea_rd_init,
nmea_wr_init,
nmea_rd_deinit,
}
ff_vecs_t ozi_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
ff_vecs_t pcx_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
}
ff_vecs_t psit_vecs = {
+ ff_type_file,
psit_rd_init,
psit_wr_init,
psit_rd_deinit,
}
ff_vecs_t psp_vecs = {
+ ff_type_file,
psp_rd_init,
psp_wr_init,
psp_rd_deinit,
ff_vecs_t quovadis_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
}
ff_vecs_t saroute_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
FIELD_DELIMITER COMMA
RECORD_DELIMITER NEWLINE
BADCHARS COMMA
+FORMAT_TYPE INTERNAL
#
# HEADER STUFF:
FIELD_DELIMITER TAB
RECORD_DELIMITER NEWLINE
BADCHARS TAB
+FORMAT_TYPE INTERNAL
#
# INDIVIDUAL DATA FIELDS:
ff_vecs_t tiger_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
}
ff_vecs_t tmpro_vecs = {
+ ff_type_file,
rd_init,
wr_init,
rd_deinit,
}
ff_vecs_t tpg_vecs = {
+ ff_type_file,
tpg_rd_init,
tpg_wr_init,
tpg_rd_deinit,
}
}
+/*
+ * Additional information for V1.
+ * Output format type at front of line.
+ */
+disp_v1(ff_type t)
+{
+ char *tstring;
+
+ switch (t) {
+ case ff_type_file: tstring = "file"; break;
+ case ff_type_serial: tstring = "serial"; break;
+ case ff_type_internal: tstring = "internal"; break;
+ default: tstring = "unknown"; break;
+ }
+ printf("%s\t", tstring);
+}
/*
* Display the available formats in a format that's easy to machine
* parse. Typically invoked by programs like graphical wrappers to
switch(version) {
case 0:
+ case 1:
for (vec = vec_list; vec->vec; vec++) {
+ if (version > 0)
+ disp_v1(vec->vec->type);
printf("%s\t%s\t%s\n", vec->name,
vec->extension? vec->extension : "",
vec->desc);
}
for (svec = style_list; svec->name; svec++) {
xcsv_read_internal_style(svec->style_buf);
+ if (version > 0)
+ disp_v1(xcsv_file.type);
printf("%s\t%s\t%s\n", svec->name, xcsv_file.extension ?
xcsv_file.extension : "", xcsv_file.description);
}
} else
+ if (ISSTOKEN(sbuff, "FORMAT_TYPE")) {
+ const char *p;
+ for (p = &sbuff[11]; *p && isspace(*p); p++) {
+ ;
+ }
+ if (ISSTOKEN(p, "INTERNAL")) {
+ xcsv_file.type = ff_type_internal;
+ }
+ /* this is almost inconcievable... */
+ if (ISSTOKEN(p, "SERIAL")) {
+ xcsv_file.type = ff_type_serial;
+ }
+ } else
+
if (ISSTOKEN(sbuff, "DESCRIPTION")) {
xcsv_file.description = csv_stringtrim(&sbuff[11],"", 0);
} else
}
ff_vecs_t xcsv_vecs = {
+ ff_type_internal,
xcsv_rd_init,
xcsv_wr_init,
xcsv_rd_deinit,